package com.service.impl;

import com.mapper.RoleMapper;
import com.pojo.C_emp_role;
import com.pojo.C_role;
import com.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class RoleServiceImpl implements RoleService {
    @Autowired
    public RoleMapper mapper;

    //    查询已启用的职位
    @Override
    public List<C_role> findByState() {
        return mapper.findByState();
    }

    //    查询全部职位
    @Override
    public List<C_role> findAllRole() {
        return mapper.findAllRole();
    }

    //    通过映射id查询职位id
    @Override
    public List<C_emp_role> findByRoleid(Integer cerid) {
        return mapper.findByRoleid(cerid);
    }

    //    添加员工，职位映射表
    @Override
    public int insertCemprole(Integer empid, Integer roleid) {
        return mapper.insertCemprole(empid, roleid);
    }

    //通过员工编号修改职位编号
    @Override
    public int updateC_emp_roleByempid(Integer roleid, Integer empid) {
        return mapper.updateC_emp_roleByempid(roleid, empid);
    }

    //    通过职位id修改职位表状态
    @Override
    public int updateC_roleByroleid(Integer state, Integer rid) {
        return mapper.updateC_roleByroleid(state, rid);
    }

    //    通过员工编号删除员工职位映射
    @Override
    public int deleteC_emp_roleByempid(Integer empid) {
        return mapper.deleteC_emp_roleByempid(empid);
    }

    //    通过员工编号查询职位id用以分别查询订单
    @Override
    public List<C_emp_role> CERselectEmpid(Integer empid) {
        return mapper.CERselectEmpid(empid);
    }
}
